package com.RedRiver.hospitalsystem.finance_service.app.controller;


import com.RedRiver.hospitalsystem.finance_service.client.DailyClient;
import com.RedRiver.hospitalsystem.finance_service.client.param.*;
import com.RedRiver.hospitalsystem.finance_service.common.WoniuxyBeanCopyUtil;
import com.RedRiver.hospitalsystem.finance_service.service.DailyService;
import com.RedRiver.hospitalsystem.finance_service.service.from.ChargeFrom;
import com.RedRiver.hospitalsystem.finance_service.service.info.ChargeAllInfo;
import com.RedRiver.hospitalsystem.finance_service.service.info.ChargeRefundInfo;
import com.RedRiver.hospitalsystem.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-04-26
 */
@RestController
@RequestMapping("/daily")
@Api(tags = "日结")
public class DailyController implements DailyClient {
    @Resource
    private DailyService dailyService;
    //根据时间查收费统计
    @ApiOperation("根据时间查收费统计")
    @PostMapping("/chargeAll")
    public Result<ChargeAllInfoClient> chargeAll(@RequestBody ChargeFromClient chargeFromClient){

        ChargeFrom copyone = WoniuxyBeanCopyUtil.copyone(chargeFromClient, ChargeFrom.class);
        ChargeAllInfo chargeAllInfo=dailyService.chargeAll(copyone);
        ChargeAllInfoClient client = WoniuxyBeanCopyUtil.copyone(chargeAllInfo, ChargeAllInfoClient.class);
        return Result.getInstance(ChargeAllInfoClient.class).setData(client);

    }

    @ApiOperation("根据时间查退费统计")
    @PostMapping("/refundAll")
    public Result<ChargeAllInfoClient> refundAll(ChargeFromClient chargeFromClient) {
        ChargeFrom copyone = WoniuxyBeanCopyUtil.copyone(chargeFromClient, ChargeFrom.class);
        ChargeAllInfo chargeAllInfo=dailyService.refundAll(copyone);
        ChargeAllInfoClient client = WoniuxyBeanCopyUtil.copyone(chargeAllInfo, ChargeAllInfoClient.class);
        return Result.getInstance(ChargeAllInfoClient.class).setData(client);
    }

    @ApiOperation("根据时间来进行日结")
    @PostMapping("/riJieAll")
    public Result<ChargeRefundInfoClient> riJieAll(ChargeFromClient chargeFromClient) {
        ChargeFrom copyone = WoniuxyBeanCopyUtil.copyone(chargeFromClient, ChargeFrom.class);
        ChargeRefundInfo chargeRefundInfo =dailyService.riJieAll(copyone);
        ChargeRefundInfoClient client = WoniuxyBeanCopyUtil.copyone(chargeRefundInfo, ChargeRefundInfoClient.class);
        return Result.getInstance(ChargeRefundInfoClient.class).setData(client);
    }


}

